package com.shuigu.controller;


import com.shuigu.response.ShuiGuResult;
import com.shuigu.pojo.dto.UserRoleDto;
import com.shuigu.pojo.dto.UserRoleParamDto;
import com.shuigu.service.ISysUserService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userRole")
public class UserRoleController {

    private final ISysUserService userService;

    public UserRoleController(ISysUserService userService) {
        this.userService = userService;
    }

    /**
     * 获取用户角色信息列表
     */
    @GetMapping("/list")
    public ShuiGuResult getList(UserRoleParamDto userRoleParamDto){
        return ShuiGuResult.success(userService.getUserRoleList(userRoleParamDto));
    }

    /**
     * 取消用户角色
     */
    @DeleteMapping("/delete")
    public ShuiGuResult deleteUserRole(Long[] ids){
        return ShuiGuResult.success(userService.deleteUserRole(ids));
    }

    /**
     * 为用户分配角色
     */
    @PostMapping("/add")
    public ShuiGuResult addUserRole(@RequestBody UserRoleDto userRoleDto){
        return ShuiGuResult.success(userService.insertUserRole(userRoleDto));
    }

    /**
     * 查询所有角色
     */
    @GetMapping("/allRole")
    public ShuiGuResult findAllRole(){
        return ShuiGuResult.success(userService.findAllRoel());
    }
}
